//斗地主
module ddz {

    export class PlayWaitMediatoDDZ extends BaseMediator {
        public static NAME: string = "PlayWaitMediatoDDZ";

        public constructor(viewComponent: any = null) {
            super(PlayWaitMediatoDDZ.NAME, viewComponent);
        }
        public listNotificationInterests(): Array<any> {
            return [
                PanelNotify.HALL.STAGE_RESIZE,
                PanelNotify.DDZ.CLOSE_PLAY_GAME,
                PanelNotify.DDZ.JOIN_ROOM,
                PanelNotify.DDZ.START_GAME,
                PanelNotify.DDZ.START_CALL_SCORE,
                PanelNotify.DDZ.END_CALL_SCORE,
                PanelNotify.DDZ.GET_SERIAL_NUMBER,
                PanelNotify.DDZ.USER_PLAY_CARD,
                PanelNotify.DDZ.USER_GIVEUP_CARD,
                PanelNotify.DDZ.GAME_OVER,
                PanelNotify.DDZ.DATA_RECOVERY_BY_PLAY,
                PanelNotify.DDZ.DATA_RECOVERY_BY_CALL,
                PanelNotify.DDZ.CLEAR_PLAY_GAME,
                PanelNotify.DDZ.MODIFY_HOSTING_STATUS,
            ];
        }
        //面板
        public panel: PlayPanelDDZ;
        //点击一张牌后的位移
        private y_axis: number = 30;
        //用於記錄用戶自己的牌，將其展示到頁面上
        private MyChessImg: Array<components.DdzPoker> = [];
        //当次我可以出的牌的组合的序号。用于提示出牌功能
        private kechuNumber: number = 0;
        //提示按钮点击的次数
        private tishiNumber: number = 0;
        //滑动选牌时已选过的牌
        private selectList = new Array();
        //已经被选中准备打出去的牌
        private chessList = new Array();

        private shp: egret.Shape = new egret.Shape();
        private pokerInitial_y = 0
        private pokerEnd_y = -30;
        //当前该我出牌 防止在别人出牌的时候我点了手牌触发牌型比较
        private myCanPlay = false;
        //点击事件和滑动事件用锁区分
        private lock = 0;//1滑动0点击
        //防止滑动选牌两个松开事件同时触发
        private lock2 = 0; //0不上锁 1 上锁
        private bet_chip = [100, 1000, 5000, 10000, 50000];//筹码规格
        private NextGameTime = null;//下一局准备倒计时，10秒不准备自动退出房间
        private CallScoreTime = null;//叫分倒计时，时间到了自动不叫
        private globLook: boolean = false;//结算过程金额不准变动
        private MovieClip: egret.MovieClip = null;//托管动画
        public handleNotification(notification: puremvc.INotification): void {
            var data: any = notification.getBody();
            switch (notification.getName()) {
                case PanelNotify.HALL.STAGE_RESIZE:
                    if (this.panel) {
                        this.panel.width = GameConfig.curWidth()
                        this.panel.height = GameConfig.curHeight()
                    }
                    break;
                case PanelNotify.DDZ.CLEAR_PLAY_GAME: {
                    this.initData();
                    break;
                }
                case PanelNotify.DDZ.CLOSE_PLAY_GAME: {
                    this.destroy();
                    break;
                };
                case PanelNotify.DDZ.JOIN_ROOM: {
                    if (this.panel && this.panel.parent) {
                        this.initUserInfo();
                    } else {//游戏中途加入有可能 先进玩家后加载房间数据，这时候面板还没起来。后台BUG
                        this.panel = null;
                        this.panel = new PlayPanelDDZ();
                        this.showUI(this.panel, 2, 5);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.JOIN_GAME_BY_HALL)
                    }
                    break;
                }
                case PanelNotify.DDZ.START_GAME: {
                    this.fapaidonghua();
                    break;
                }
                case PanelNotify.DDZ.START_CALL_SCORE: {
                    this.WaitingForAScore();
                    break;
                }
                case PanelNotify.DDZ.END_CALL_SCORE: {
                    this.endForAscore();
                    break;
                }
                case PanelNotify.DDZ.USER_PLAY_CARD: {
                    this.playCards();
                    break;
                }
                case PanelNotify.DDZ.USER_GIVEUP_CARD: {
                    this.giveUpCards();
                    break;
                }
                case PanelNotify.DDZ.GAME_OVER: {
                    this.gameover();
                    break;
                }
                case PanelNotify.DDZ.GET_SERIAL_NUMBER: {
                    this.initRoomInfo()
                    break;
                }
                case PanelNotify.DDZ.DATA_RECOVERY_BY_PLAY: {
                    this.dataRecoveryByPlay();
                    break;
                }
                case PanelNotify.DDZ.DATA_RECOVERY_BY_CALL: {
                    this.dataRecoveryByCall();
                    break;

                }
                case PanelNotify.DDZ.MODIFY_HOSTING_STATUS: {
                    this.modifyTuoGuan();
                    break;
                }
            }
        }
        //初始化面板ui
        public initUI(): void {
            if (InstructionsEnum.SOUND_GAME != InstructionsEnum.GAME_SOUND_NAME.DDZ) {
                SoundManage.stopYinYue();
                InstructionsEnum.SOUND_GAME = InstructionsEnum.GAME_SOUND_NAME.DDZ
                SoundManage.startYinYueLoad();
            }
            //将滚动公告转移到当前面板
            EffectUtils.moveNoticeToPanel(this.panel.noticeGroup)

            this.panel.trusteeship.addEventListener(egret.TouchEvent.TOUCH_TAP, this.trusteeshipClick, this);
            this.panel.tuoguanBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.trusteeshiclose, this);

            this.panel.menu_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.menu_click, this)
            this.panel.menu_fankui.addEventListener(egret.TouchEvent.TOUCH_TAP, this.fankuiClick, this)
            this.panel.menu_jilu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.jiluClick, this)
            this.panel.menu_exit.addEventListener(egret.TouchEvent.TOUCH_TAP, this.fanhuidatingClick, this);
            this.panel.menu_help.addEventListener(egret.TouchEvent.TOUCH_TAP, this.helpClick, this);
            this.panel.menu_set.addEventListener(egret.TouchEvent.TOUCH_TAP, this.setClick, this);

            this.panel.zhunbei.addEventListener(egret.TouchEvent.TOUCH_TAP, this.zhunbeiClick, this);
            //出牌
            this.panel.chupai.addEventListener(egret.TouchEvent.TOUCH_TAP, this.chupai, this);
            this.panel.chongxuan.addEventListener(egret.TouchEvent.TOUCH_TAP, this.chongxuan, this);
            this.panel.tishi.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tishi, this);
            this.panel.buchu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buchu, this);
            //叫分
            this.panel.bujiao.addEventListener(egret.TouchEvent.TOUCH_TAP, this.callScoreClick, this);
            this.panel.fen1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.callScoreClick, this);
            this.panel.fen2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.callScoreClick, this);
            this.panel.fen3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.callScoreClick, this);

        };

        //初始化面板数据
        public initData(): void {
            InstructionsEnum.isHall = true;
            //清楚界面所有数据
            this.globLook = false
            this.clearView();
            this.initRoomInfo();
            this.initUserInfo();
        }
        //销毁UI
        public destroy(): void {
            InstructionsEnum.isHall = false;
            Global.removeTimeOut(InstructionsEnum.GAME_TIMEOUT_LIST)
            Global.removeInterval(InstructionsEnum.GAME_INTERVAL_LIST)
            this.NextGameTime = null;
            if (this.panel) {
                this.panel.game_ok_my.destroy()
            }
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.CLOSE_HELP);
            this.closePanel(1);
        }
        //初始化房间信息
        private initRoomInfo() {
            this.panel.beishu.text = "倍数：" + DdzVO.getVo().cbIsDoubleNumber;
            this.panel.difen.text = "底分：" + DdzVO.getVo().lCellScore / 100;
            this.panel.bianhao.text = "局号：" + DdzVO.getVo().gameNumbering;

            if (InstructionsEnum.LEVEL_GAME == 1 || InstructionsEnum.LEVEL_GAME == 10) {
                this.panel.roomLevel.source = "DDZ_roomLevel_1";
            } else
                if (InstructionsEnum.LEVEL_GAME == 2 || InstructionsEnum.LEVEL_GAME == 11) {
                    this.panel.roomLevel.source = "DDZ_roomLevel_2";
                } else
                    if (InstructionsEnum.LEVEL_GAME == 3 || InstructionsEnum.LEVEL_GAME == 12) {
                        this.panel.roomLevel.source = "DDZ_roomLevel_3";
                    }
        }
        //初始化玩家信息
        private initUserInfo() {
            if (Global.isNotEmpty(GameVO.getVo().dwUserID)) {
                this.panel.source_my.source = "special_" + GameVO.getVo().wFaceID % 15;
                this.panel.name_my.text = Global.cutString(GameVO.getVo().szNickName);
                if (!this.globLook) {
                    this.panel.glod_my.text = DdzVO.getVo().lUserScore / 100 + "";
                }
                if (DdzVO.getVo().status_my === 3) {
                    this.panel.my_ready.visible = true;
                    Global.removeTimeOut(InstructionsEnum.GAME_TIMEOUT_LIST)
                    this.NextGameTime = null;
                    this.panel.game_ok_my.destroy()
                } else {
                    this.panel.my_ready.visible = false;
                }
                if (DdzVO.getVo().status_my === 2) {
                    this.panel.zhunbei.visible = true;
                    this.nextGameTimeout();
                } else {
                    this.panel.zhunbei.visible = false;
                }
            }
            if (Global.isNotEmpty(DdzVO.getVo().id_right)) {
                this.panel.userInfoRight.visible = true;
                this.panel.gold_right.text = DdzVO.getVo().gold_right / 100 + ""
                this.panel.source_right.source = "special_" + DdzVO.getVo().faceId_right % 15;
                if (DdzVO.getVo().status_right === 3) {
                    this.panel.R_ready.visible = true;
                } else {
                    this.panel.R_ready.visible = false;
                }
            } else {
                this.panel.userInfoRight.visible = false;
            }
            if (Global.isNotEmpty(DdzVO.getVo().id_left)) {
                this.panel.userInfoLeft.visible = true;
                this.panel.gold_left.text = DdzVO.getVo().gold_left / 100 + ""
                this.panel.source_left.source = "special_" + DdzVO.getVo().faceId_left % 15;
                if (DdzVO.getVo().status_left === 3) {
                    this.panel.L_ready.visible = true;
                } else {
                    this.panel.L_ready.visible = false;
                }
            } else {
                this.panel.userInfoLeft.visible = false;
            }

            if (Global.isNotEmpty(DdzVO.getVo().wBankerUser)) {
                if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_my) {
                    this.panel.zhuangImg_my.visible = true;
                };
                if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_right) {
                    this.panel.zhuangImg_right.visible = true;
                };
                if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_left) {
                    this.panel.zhuangImg_left.visible = true;
                };
            }
        }
        private fapaidonghua() {
            this.clearView();
            this.initRoomInfo();
            this.initUserInfo();
            Global.removeTimeOut(InstructionsEnum.GAME_TIMEOUT_LIST)
            this.panel.daojishi_L.visible = false
            this.panel.daojishi_R.visible = false
            this.panel.daojishi_my.visible = false
            this.NextGameTime = null;
            this.panel.game_ok_my.destroy()
            this.panel.winer_img.visible = false
            this.panel.zhunbei.visible = false;
            this.panel.my_ready.visible = false;
            this.panel.R_ready.visible = false;
            this.panel.L_ready.visible = false;
            this.panel.jiaofenGroup.visible = false
            this.panel.R_chess.source = "DDZ_source_34";
            this.panel.L_chess.source = "DDZ_source_34";
            var thisBack = this;
            //发牌
            var fapai = function () {
                var leftNum = 0
                var rightNum = 0
                var a = 0;
                var t1 = egret.setInterval(() => {
                    let img = new eui.Image("DDZ_source_34")
                    img.x = thisBack.panel.width / 2 - 25
                    img.y = thisBack.panel.height / 2 - 100
                    thisBack.panel.fapai_group.addChild(img);
                    egret.Tween.get(img).to({ x: thisBack.panel.userInfoLeft.x + thisBack.panel.L_chess.x, y: thisBack.panel.userInfoLeft.y + thisBack.panel.L_chess.y }, 100).call((img: eui.Image) => {
                        egret.Tween.removeTweens(img)
                        if (img.parent) {
                            img.parent.removeChild(img)
                        }
                        leftNum++
                        thisBack.panel.L_chessNum.text = leftNum + "";
                    }, this, [img])
                    a++
                    if (a >= 17) {
                        egret.clearInterval(t1)
                    }
                }, this, 100)
                var b = 0
                var t2 = egret.setInterval(() => {
                    let img = new eui.Image("DDZ_source_34")
                    img.x = thisBack.panel.width / 2 - 25
                    img.y = thisBack.panel.height / 2 - 100
                    thisBack.panel.fapai_group.addChild(img);
                    egret.Tween.get(img).to({ x: thisBack.panel.userInfoRight.x + thisBack.panel.R_chess.x, y: thisBack.panel.userInfoRight.y + thisBack.panel.R_chess.y }, 100).call((img: eui.Image) => {
                        egret.Tween.removeTweens(img)
                        if (img.parent) {
                            img.parent.removeChild(img)
                        }
                        rightNum++
                        thisBack.panel.R_chessNum.text = rightNum + "";
                    }, this, [img])
                    b++
                    if (b >= 17) {
                        egret.clearInterval(t2)
                    }
                }, this, 100)
                var c = 0;
                var t3 = egret.setInterval(() => {
                    let img = new eui.Image("DDZ_source_34")
                    // img.x = thisBack.panel.width / 2 - 25
                    img.horizontalCenter = 0;
                    img.y = thisBack.panel.height / 2 - 100
                    thisBack.panel.fapai_group.addChild(img);
                    egret.Tween.get(img).to({ y: thisBack.panel.myChessGroup.y, width: 126, height: 170 }, 100);
                    c++
                    if (c >= 17) {
                        egret.clearInterval(t3)
                        fanpai(img)
                    }
                }, this, 100)
            }
            //翻牌
            var fanpai = function (img: eui.Image) {
                thisBack.panel.fapai_group.removeChildren();
                img.anchorOffsetX = img.width / 2
                img.x += img.width / 2
                thisBack.panel.fapai_group.addChild(img);
                EffectUtils.xuanZuanHuanTu(img, Global.getPokerByObjectForDDZ(DdzVO.getVo().chessListMy[DdzVO.getVo().chessListMy.length - 1]), 500, () => {
                    egret.Tween.removeTweens(img)
                    if (img.parent) {
                        img.parent.removeChild(img)
                    }
                    thisBack.Licensing();
                })
            }

            var json = RES.getRes("game_start_json")
            var text = RES.getRes("game_start")
            var mcDataFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(json, text)
            var nodemv: egret.MovieClip = new egret.MovieClip(mcDataFactory.generateMovieClipData())
            if (Global.isNotEmpty(nodemv)) {
                nodemv.x = thisBack.panel.width / 2 - nodemv.width / 2
                nodemv.y = thisBack.panel.height / 2 - nodemv.height / 2
                thisBack.panel.addChild(nodemv);
                nodemv.addEventListener(egret.Event.COMPLETE, () => {
                    thisBack.panel.removeChild(nodemv);
                    fapai();
                }, this)
                nodemv.play();
            } else {
                fapai();
            }
        }
        //发牌
        private Licensing() {
            var thisBack = this;
            //发牌动画
            this.MyChessImg = new Array();
            for (let i = 0; i < DdzVO.getVo().chessListMy.length; i++) {
                this.panel["my_chess" + i].y = this.pokerInitial_y;
                this.panel["my_chess" + i].name = DdzVO.getVo().chessListMy[i].id;
                let chushiX = this.panel["my_chess" + i].x;
                this.panel["my_chess" + i].x = 350;
                var poker: components.DdzPoker = this.panel["my_chess" + i]
                poker.init(DdzVO.getVo().chessListMy[i]);
                egret.Tween.get(this.panel["my_chess" + i]).to({ x: chushiX }, 500).call((image: components.DdzPoker) => {
                    egret.Tween.removeTweens(image);
                }, this, [this.panel["my_chess" + i]]);
                this.MyChessImg.push(this.panel["my_chess" + i]);
            };
            //展示地主牌
            for (let i = 0; i < 3; i++) {
                let chushiX = this.panel["dizhu_chess" + i].x;
                this.panel["dizhu_chess" + i].x = 1280;
                this.panel["dizhu_chess" + i].source = "DDZ_source_34";
                egret.Tween.get(this.panel["dizhu_chess" + i]).to({ x: chushiX }, 500).wait(50).call((image: eui.Image) => {
                    egret.Tween.removeTweens(image);
                }, this, [this.panel["dizhu_chess" + i]]);
            }
            //记牌器排除我的手牌
            for (let i = 0; i < DdzVO.getVo().cbCardData.length; i++) {
                let poker = Poker_DDZ.chessArray[DdzVO.getVo().cbCardData[i]];
                let value = poker.value;
                if (Global.isNotEmpty(DdzVO.getVo().chessListWhole[value])) {
                    DdzVO.getVo().chessListWhole[value]--;
                }
            }
            //刷新记牌器
            this.updateRecorder();
            this.panel.daojishi_L.visible = true
            this.panel.daojishi_R.visible = true
            this.panel.daojishi_my.visible = true
            this.panel.jiaofenGroup.visible = true;
            egret.setTimeout(() => {
                thisBack.panel.trusteeship.visible = true;
                //给手牌容器添加滑动选牌事件
                thisBack.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_BEGIN, thisBack.anzhu, this);
                thisBack.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_END, thisBack.songkai, this);
                thisBack.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, thisBack.songkai2, this);
                //给手牌添加点击事件
                for (let i = 0; i < 20; i++) {
                    thisBack.panel["my_chess" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, thisBack.clickChess, this);
                }
            }, this, 500)
        };
        //点击叫分
        private callScoreClick(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            var fen
            if (event.currentTarget == this.panel.bujiao) {
                fen = 255
            }
            if (event.currentTarget == this.panel.fen1) {
                fen = 1
            }
            if (event.currentTarget == this.panel.fen2) {
                fen = 2
            }
            if (event.currentTarget == this.panel.fen3) {
                fen = 3
            }
            let obj = {
                cbCallScore: fen
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_CallSocre, obj);
        }
        //叫分返回
        private WaitingForAScore() {
            this.panel.bujiao.visible = false;
            this.panel.fen1.visible = false;
            this.panel.fen2.visible = false;
            this.panel.fen3.visible = false;

            this.panel.fen_my.source = "";
            this.panel.fen_left.source = "";
            this.panel.fen_right.source = "";

            this.panel.game_ok_right.visible = false;
            this.panel.game_ok_my.visible = false;
            this.panel.game_ok_left.visible = false;

            //自己叫分时显示面板，别人叫分时显示等待
            let upCallScoreUser = DdzVO.getVo().wCallScoreUser;
            let nextCallScoreUser = DdzVO.getVo().wCurrentUser;
            let fenNumber = DdzVO.getVo().cbUserCallScore;
            if (fenNumber == 255) {
                fenNumber = 0;
            }
            //上次有人叫分
            if (upCallScoreUser == DdzVO.getVo().wChairId_my) {
                egret.clearTimeout(this.CallScoreTime)//清楚自动叫分定时器
                this.panel.fen_my.source = "DDZ_fen_" + fenNumber;
                EffectUtils.shakeObj(this.panel.fen_my);
            }
            if (upCallScoreUser == DdzVO.getVo().wChairId_left) {
                this.panel.fen_left.source = "DDZ_fen_" + fenNumber;
                EffectUtils.shakeObj(this.panel.fen_left);
            }
            if (upCallScoreUser == DdzVO.getVo().wChairId_right) {
                this.panel.fen_right.source = "DDZ_fen_" + fenNumber;
                EffectUtils.shakeObj(this.panel.fen_right);
            }
            SoundManage.startYinxiaoLoad("female_" + fenNumber + "_point_mp3", 1);
            //下次叫分的人
            if (nextCallScoreUser == DdzVO.getVo().wChairId_my) {
                this.panel.bujiao.visible = true;
                this.panel.fen1.visible = true;
                this.panel.fen2.visible = true;
                this.panel.fen3.visible = true;
                this.panel.bujiao.enabled = true;
                this.panel.fen1.enabled = true;
                this.panel.fen2.enabled = true;
                this.panel.fen3.enabled = true;

                this.panel.game_ok_my.init(DdzVO.getVo().cbTimeCallScore);
                if (fenNumber >= 1) {
                    this.panel.fen1.enabled = false;
                }
                if (fenNumber >= 2) {
                    this.panel.fen2.enabled = false;
                }
                //自己叫分时添加倒计时，倒计时到了自动不叫，本来该后台做托管后台没做只好前端做了
                this.CallScoreTime = egret.setTimeout(() => {
                    let obj = {
                        cbCallScore: 255
                    }
                    SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_CallSocre, obj);
                }, this, DdzVO.getVo().cbTimeCallScore * 1000)
            }
            if (nextCallScoreUser == DdzVO.getVo().wChairId_right) {
                this.panel.game_ok_right.visible = true;
                this.panel.game_ok_right.init(DdzVO.getVo().cbTimeCallScore);
            }
            if (nextCallScoreUser == DdzVO.getVo().wChairId_left) {
                this.panel.game_ok_left.visible = true;
                this.panel.game_ok_left.init(DdzVO.getVo().cbTimeCallScore);
            }

        }
        //叫分结束翻开地主牌
        private endForAscore() {
            this.initRoomInfo();
            egret.clearTimeout(this.CallScoreTime)//清楚自动叫分定时器
            this.panel.game_ok_right.visible = false;
            this.panel.game_ok_my.visible = false;
            this.panel.game_ok_left.visible = false;

            this.panel.bujiao.visible = false;
            this.panel.fen1.visible = false;
            this.panel.fen2.visible = false;
            this.panel.fen3.visible = false;

            this.panel.bujiao.enabled = false;
            this.panel.fen1.enabled = false;
            this.panel.fen2.enabled = false;
            this.panel.fen3.enabled = false;

            egret.setTimeout(function () {
                this.panel.fen_my.source = "";
                this.panel.fen_left.source = "";
                this.panel.fen_right.source = "";
            }, this, 500);
            let chess = DdzVO.getVo().chessListBanker;
            for (let i = 0; i < chess.length; i++) {
                let img = Global.getPokerByObjectForDDZ(chess[i]);
                EffectUtils.xuanZuanHuanTu(this.panel["dizhu_chess" + i], img);
            }
            this.initChessImg(PanelNotify.DDZ.END_CALL_SCORE);
            //更新地主头像
            this.initUserInfo();
            let img;
            if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_my) {
                //记牌器排除地主牌
                for (let i = 0; i < DdzVO.getVo().cbBankerCard.length; i++) {
                    let poker = Poker_DDZ.chessArray[DdzVO.getVo().cbBankerCard[i]];
                    let value = poker.value;
                    if (Global.isNotEmpty(DdzVO.getVo().chessListWhole[value])) {
                        DdzVO.getVo().chessListWhole[value]--;
                    }
                }
                this.updateRecorder();
                img = this.panel.zhuangImg_my;
                this.playCards();
            };
            if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_right) {
                img = this.panel.zhuangImg_right;
            };
            if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_left) {
                img = this.panel.zhuangImg_left;
            };
            if (Global.isNotEmpty(img)) {
                EffectUtils.Twinkle(img);
            }

            let wCurrentUser = DdzVO.getVo().wCurrentUser;
            if (wCurrentUser == DdzVO.getVo().wChairId_my) {
                this.panel.game_ok_my.init(DdzVO.getVo().cbTimeOutCard);
            }
            if (wCurrentUser == DdzVO.getVo().wChairId_right) {
                this.panel.game_ok_right.init(DdzVO.getVo().cbTimeOutCard);
            }
            if (wCurrentUser == DdzVO.getVo().wChairId_left) {
                this.panel.game_ok_left.init(DdzVO.getVo().cbTimeOutCard);
            }
        }
        //点击不出
        private buchu(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_PassCard, {});
            this.chongxuan_tishi();
        }
        //点击出牌
        private chupai(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            if (this.chessList.length == 0) {
                return;
            }
            let obj = {
                cbCardCount: this.chessList.length,
                cbCardData: this.chessList
            }
            RegDataDdz.CMD_GP_OutCard.nLenght = this.chessList.length + 1;
            RegDataDdz.CMD_GP_OutCard.data[1][2] = this.chessList.length;
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_OutCard, obj);
        }
        //清空选中的牌
        private chongxuan_tishi() {
            this.chessList.splice(0, this.chessList.length)
            for (var i = 0; i < this.MyChessImg.length; i++) {
                this.MyChessImg[i].y = this.pokerInitial_y;
            }
        }
        //点击提示
        private tishi(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            this.panel.tishi.enabled = false;
            let t = egret.setTimeout(() => {//防止玩家疯狂点提示
                this.panel.tishi.enabled = true;
                egret.clearTimeout(t)
            }, this, 100)

            this.chongxuan_tishi();
            if (DdzVO.getVo().canPlayType == 1) {//我可以随意出
                this.MyChessImg[this.MyChessImg.length - 1 - this.tishiNumber].y = this.pokerEnd_y;
                this.chessList.push(this.MyChessImg[this.MyChessImg.length - 1 - this.tishiNumber].name);
                this.panel.chupai.visible = true;
                this.panel.chupai.enabled = true;
                this.tishiNumber++;
                if (this.tishiNumber == this.MyChessImg.length) {
                    this.tishiNumber = 0;
                }
            } else {
                var mykechuMap = DdzVO.getVo().canPlayGroup;
                if (mykechuMap.length == 0) {
                    this.buchu(null);
                    return;
                }
                var mykechu: Array<Poker_DDZ> = mykechuMap[this.kechuNumber];
                for (var i = 0; i < mykechu.length; i++) {
                    for (let k in this.MyChessImg) {
                        if (this.MyChessImg[k].name == mykechu[i].id + "") {
                            this.MyChessImg[k].y = this.pokerEnd_y;
                            this.chessList.push(this.MyChessImg[k].name);
                        }
                    }
                }
                this.panel.chupai.visible = true;
                this.panel.chupai.enabled = true;
                if (this.kechuNumber < mykechuMap.length - 1) {
                    this.kechuNumber++;
                } else {
                    this.kechuNumber = 0;
                }
            }

        }
        //出牌返回
        private playCards() {
            this.panel.buchu.visible = false;
            this.panel.tishi.visible = false;
            this.panel.chupai.visible = false;
            this.panel.chongxuan.visible = false;

            this.panel.buchu.enabled = true;
            this.panel.tishi.enabled = true;
            this.panel.chupai.enabled = true;
            this.panel.chongxuan.enabled = true;


            this.myCanPlay = false;
            this.panel.game_ok_right.visible = false;
            this.panel.game_ok_my.visible = false;
            this.panel.game_ok_left.visible = false;
            this.panel.r_too.source = ""
            this.panel.l_too.source = ""
            this.panel.my_too.source = ""
            //展示上次出的牌
            if (Global.isNotEmpty(DdzVO.getVo().upPlayList)) {
                //谁家出的牌就清空上次出的牌
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_right) {
                    this.panel.right_playGroup.removeChildren();
                    this.panel.left_playGroup.removeChildren();
                    DdzVO.getVo().chessListRightLength -= DdzVO.getVo().upPlayList.length;
                    this.updateRecorder();
                }
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_left) {
                    this.panel.left_playGroup.removeChildren();
                    this.panel.my_playGroup.removeChildren();
                    DdzVO.getVo().chessListLeftLength -= DdzVO.getVo().upPlayList.length;
                    this.updateRecorder();
                }
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {
                    this.panel.my_playGroup.removeChildren();
                    this.panel.right_playGroup.removeChildren();
                    for (let i = 0; i < DdzVO.getVo().upPlayList.length; i++) {
                        let index = DdzVO.getVo().cbCardData.indexOf(DdzVO.getVo().upPlayList[i]);
                        if (index != -1) {
                            DdzVO.getVo().cbCardData.splice(index, 1);
                        }
                    }
                    DdzVO.getVo().chessListMy = Poker_DDZ.idChangeObject(DdzVO.getVo().cbCardData);
                    DdzVO.getVo().chessListMy = Poker_DDZ.sort(DdzVO.getVo().chessListMy);
                    //出牌后重置手牌
                    this.initChessImg();
                }
                DdzVO.getVo().chessListUp = Poker_DDZ.idChangeObject(DdzVO.getVo().upPlayList);
                DdzVO.getVo().chessListUp = Poker_DDZ.sort(DdzVO.getVo().chessListUp);
                //生成刚出的牌
                var img: components.DdzPoker = null;
                for (var i = 0; i < DdzVO.getVo().chessListUp.length; i++) {
                    let end_x = 0;//牌动画最终目标位置
                    img = new components.DdzPoker();
                    img.init(DdzVO.getVo().chessListUp[i]);
                    img.scaleX = 0.7;
                    img.scaleY = 0.7;
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_right) {
                        img.x = -30;
                        if (DdzVO.getVo().upPlayList.length <= 10) {
                            img.x = DdzVO.getVo().upPlayList.length * 30
                            end_x = i * 30;
                        } else {
                            img.x = 10 * 30;
                            if (i < 10) {
                                end_x = i * 30;
                            } else {
                                img.y = 60;
                                end_x = (10 - (DdzVO.getVo().upPlayList.length - i)) * 30
                            }
                        }
                        this.panel.right_playGroup.addChild(img);
                    }
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_left) {
                        img.x = 0;
                        end_x = i * 30;
                        if (i >= 10) {
                            end_x = (i - 10) * 30;
                            img.y = 60;
                        }
                        this.panel.left_playGroup.addChild(img);
                    }
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {
                        img.x = 0;
                        end_x = i * 30;
                        this.panel.my_playGroup.addChild(img);
                    }
                    egret.Tween.get(img).to({ x: end_x }, 400).call((img: eui.Image) => {
                        egret.Tween.removeTweens(img);
                    }, this, [img])
                }
                //出牌的是地主 最后一张显示地主标志
                if (img != null && DdzVO.getVo().wOutCardUser == DdzVO.getVo().wBankerUser) {
                    img.init(DdzVO.getVo().chessListUp[i - 1], true);
                }

                //游戏中的特效展示//炸弹、飞机、双王以及语音播放
                if (Global.isNotEmpty(DdzVO.getVo().wOutCardUser)) {
                    DdzVO.getVo().upPlayType = ChessType.getType(DdzVO.getVo().chessListUp);
                    this.sound(DdzVO.getVo().upPlayType, DdzVO.getVo().wOutCardUser);
                }
                //剩余2张牌警告
                let leng = null;
                let jingbao = false;
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_right) {
                    if (DdzVO.getVo().chessListRightLength < 3 && DdzVO.getVo().chessListRightLength > 0) {
                        EffectUtils.shakeObj(this.panel.R_chessNum);
                        if (this.panel.jingbao_right.visible == false) {
                            this.panel.jingbao_right.visible = true;
                            EffectUtils.Twinkle(this.panel.jingbao_right, -1, 300)
                        }
                        jingbao = true;
                        leng = DdzVO.getVo().chessListRightLength;
                    }
                }
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_left) {
                    if (DdzVO.getVo().chessListLeftLength < 3 && DdzVO.getVo().chessListLeftLength > 0) {
                        EffectUtils.shakeObj(this.panel.L_chessNum);
                        if (this.panel.jingbao_left.visible == false) {
                            this.panel.jingbao_left.visible = true;
                            EffectUtils.Twinkle(this.panel.jingbao_left, -1, 300)
                        }
                        jingbao = true;
                        leng = DdzVO.getVo().chessListLeftLength;
                    }
                }
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {
                    if (DdzVO.getVo().chessListMy.length < 3 && DdzVO.getVo().chessListMy.length < 0) {
                        jingbao = true;
                        leng = DdzVO.getVo().chessListMy.length;
                    }
                }
                if (jingbao) {
                    egret.setTimeout(() => {
                        SoundManage.startYinxiaoLoad("female_chess_" + leng + "_mp3", 1);
                    }, this, 500)
                }
            }
            //刷新余牌数量
            this.panel.R_chessNum.text = DdzVO.getVo().chessListRightLength + "";
            this.panel.L_chessNum.text = DdzVO.getVo().chessListLeftLength + "";

            //显示下个出牌人
            if (Global.isNotEmpty(DdzVO.getVo().wCurrentUser)) {
                if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wChairId_my) {
                    this.myCanPlay = true;
                    this.kechuNumber = 0;
                    this.panel.buchu.horizontalCenter = -275
                    this.panel.buchu.visible = true;
                    this.panel.buchu.icon = "DDZ_source_3";
                    this.panel.tishi.visible = true;
                    this.panel.chupai.visible = true;
                    this.panel.chongxuan.visible = true;

                    this.panel.game_ok_my.init(DdzVO.getVo().cbTimeOutCard);
                    //两次出牌人是同一个只有火箭的情况，这个时候由于后台没有其他两家过牌的操作
                    //前台需要自己清理上次的牌型，否则会出现自己提示自己打不过上家的BUG
                    if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wOutCardUser) {
                        DdzVO.getVo().chessListUp = [];
                        DdzVO.getVo().upPlayType = null;
                        let t = egret.setTimeout(() => {
                            this.panel.my_playGroup.removeChildren();
                            this.panel.right_playGroup.removeChildren();
                            this.panel.left_playGroup.removeChildren();
                            egret.clearTimeout(t);
                        }, this, 1000);
                    }
                    if (DdzVO.getVo().chessListUp.length == 0) {//首次出牌必出
                        this.panel.buchu.enabled = false;
                    }
                    //轮到我出牌算提示
                    DdzVO.getVo().canPlayGroup = ChessTips.find(DdzVO.getVo().chessListMy, DdzVO.getVo().chessListUp);
                    //要不起，按钮全部隐藏只显示不出
                    if (DdzVO.getVo().canPlayGroup.length == 0 && DdzVO.getVo().canPlayType != 1) {
                        this.panel.tishi.visible = false;
                        this.panel.chongxuan.visible = false;
                        this.panel.chupai.visible = false;

                        this.panel.buchu.enabled = true;
                        this.panel.buchu.icon = "DDZ_source_26";
                        this.panel.buchu.horizontalCenter = 0;
                    } else {
                        //计算我已提前选中的牌能否出牌
                        this.compare();
                    }
                }
                if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wChairId_right) {
                    this.panel.game_ok_right.visible = true;
                    this.panel.game_ok_right.init(DdzVO.getVo().cbTimeOutCard);
                }
                if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wChairId_left) {
                    this.panel.game_ok_left.visible = true;
                    this.panel.game_ok_left.init(DdzVO.getVo().cbTimeOutCard);
                }
            }
        }
        //弃牌返回
        private giveUpCards() {
            this.panel.buchu.visible = false;
            this.panel.tishi.visible = false;
            this.panel.chupai.visible = false;
            this.panel.chongxuan.visible = false;

            this.panel.buchu.enabled = true;
            this.panel.tishi.enabled = true;
            this.panel.chupai.enabled = true;
            this.panel.chongxuan.enabled = true;

            this.myCanPlay = false;

            this.panel.game_ok_right.visible = false;
            this.panel.game_ok_my.visible = false;
            this.panel.game_ok_left.visible = false;
            let img: eui.Image = null;
            if (DdzVO.getVo().wPassCardUser == DdzVO.getVo().wChairId_right) {
                this.panel.right_playGroup.removeChildren();
                this.panel.left_playGroup.removeChildren();
                this.panel.r_too.source = "DDZ_source_2";
                img = this.panel.r_too
            }
            if (DdzVO.getVo().wPassCardUser == DdzVO.getVo().wChairId_left) {
                this.panel.left_playGroup.removeChildren();
                this.panel.my_playGroup.removeChildren();
                this.panel.l_too.source = "DDZ_source_2";
                img = this.panel.l_too
            }
            if (DdzVO.getVo().wPassCardUser == DdzVO.getVo().wChairId_my) {
                this.panel.my_playGroup.removeChildren();
                this.panel.right_playGroup.removeChildren();
                this.panel.my_too.source = "DDZ_source_2";
                img = this.panel.my_too
            }
            let t = egret.setTimeout(() => {
                try {
                    img.source = "";
                    egret.clearTimeout(t)
                } catch (e) {
                    egret.clearTimeout(t)
                }
            }, this, 2000);
            SoundManage.startYinxiaoLoad("female_guo_mp3", 1);
            if (DdzVO.getVo().cbTurnOver == 1) {//弃牌过一圈就清空所有出的牌和状态
                DdzVO.getVo().chessListUp = [];
                DdzVO.getVo().upPlayType = null;
                this.panel.right_playGroup.removeChildren();
                this.panel.left_playGroup.removeChildren();
                this.panel.my_playGroup.removeChildren();
            }
            //显示下个出牌人
            if (Global.isNotEmpty(DdzVO.getVo().wCurrentUser)) {
                if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wChairId_my) {
                    this.panel.game_ok_my.init(DdzVO.getVo().cbTimeOutCard);
                    this.myCanPlay = true;
                    this.kechuNumber = 0;
                    this.panel.tishi.visible = true;
                    this.panel.chupai.visible = true;
                    this.panel.chongxuan.visible = true;
                    this.panel.buchu.visible = true;
                    this.panel.buchu.horizontalCenter = -275
                    this.panel.buchu.icon = "DDZ_source_3";

                    this.panel.tishi.enabled = true;
                    this.panel.chupai.enabled = true;
                    this.panel.chongxuan.enabled = true;
                    this.panel.buchu.enabled = true;


                    //轮到我出牌算提示
                    if (DdzVO.getVo().chessListUp.length == 0) {//首次出牌必出
                        this.panel.buchu.enabled = false;
                    }
                    DdzVO.getVo().canPlayGroup = ChessTips.find(DdzVO.getVo().chessListMy, DdzVO.getVo().chessListUp);
                    //要不起，按钮全部隐藏只显示不出
                    if (DdzVO.getVo().canPlayGroup.length == 0 && DdzVO.getVo().canPlayType != 1) {
                        this.panel.buchu.enabled = true;
                        this.panel.buchu.icon = "DDZ_source_26"
                        this.panel.buchu.horizontalCenter = 0

                        this.panel.tishi.visible = false;
                        this.panel.chongxuan.visible = false;
                        this.panel.chupai.visible = false;
                    } else {
                        //计算我已提前选中的牌能否出牌
                        this.compare();
                    }
                }
                if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wChairId_right) {
                    this.panel.game_ok_right.visible = true;
                    this.panel.game_ok_right.init(DdzVO.getVo().cbTimeOutCard);
                }
                if (DdzVO.getVo().wCurrentUser == DdzVO.getVo().wChairId_left) {
                    this.panel.game_ok_left.visible = true;
                    this.panel.game_ok_left.init(DdzVO.getVo().cbTimeOutCard);
                }
            }
        }
        //游戏结束，显示所有玩家手牌
        private gameover() {
            this.globLook = true
            this.initRoomInfo();
            this.panel.trusteeship.visible = false;
            egret.Tween.removeTweens(this.panel.jingbao_left)
            egret.Tween.removeTweens(this.panel.jingbao_right)
            this.panel.jingbao_left.visible = false
            this.panel.jingbao_right.visible = false

            var thisback = this;
            DdzVO.getVo().game_state = 0;
            //翻开剩的牌
            if (DdzVO.getVo().chessListRightOver != null && DdzVO.getVo().chessListRightOver.length != 0) {
                this.panel.right_playGroup.removeChildren();
                let chessList = Poker_DDZ.idChangeObject(DdzVO.getVo().chessListRightOver)
                chessList = Poker_DDZ.sort(chessList)
                for (let i = 0; i < chessList.length; i++) {
                    let image: eui.Image = new eui.Image;
                    image.x = -30;
                    image.scaleX = 0.7;
                    image.scaleY = 0.7;
                    image.source = Global.getPokerByObjectForDDZ(chessList[i]);
                    let end_x = 0;
                    if (i < 10) {
                        if (chessList.length < 10) {
                            end_x = -30 - (chessList.length - i) * 30;
                        } else {
                            end_x = -30 - (10 - i) * 30;
                        }
                    } else {
                        end_x = -30 - ((chessList.length - 10) - (i - 10)) * 30;
                        image.y = 60;
                    }
                    this.panel.right_playGroup.addChild(image);
                    egret.Tween.get(image).to({ x: end_x }, 400).call((img: eui.Image) => {
                        egret.Tween.removeTweens(image);
                    }, this, [image]);
                }
            }
            if (DdzVO.getVo().chessListLeftOver != null && DdzVO.getVo().chessListLeftOver.length != 0) {
                this.panel.left_playGroup.removeChildren();
                let chessList = Poker_DDZ.idChangeObject(DdzVO.getVo().chessListLeftOver)
                chessList = Poker_DDZ.sort(chessList)
                for (let i = 0; i < chessList.length; i++) {
                    let image: eui.Image = new eui.Image;
                    image.x = 0;
                    image.scaleX = 0.7;
                    image.scaleY = 0.7;
                    image.source = Global.getPokerByObjectForDDZ(chessList[i]);
                    let end_x = 0;
                    end_x = i * 30;
                    if (i >= 10) {
                        end_x = (i - 10) * 30;
                        image.y = 60;
                    }
                    this.panel.left_playGroup.addChild(image);
                    egret.Tween.get(image).to({ x: end_x }, 400).call((image: eui.Image) => {
                        egret.Tween.removeTweens(image);
                    }, this, [image])
                }
            }
            //输家向赢家飞金币动画
            var GoldCoin: Function = function (panel: eui.Component, end_x, end_y, start_x, start_y, gold) {
                let chouma = thisback.qiegeJinbi(gold)
                for (let k = 0; k < chouma.length; k++) {
                    let image = new eui.Image();
                    image.source = "bet_" + (chouma[k] / 100);
                    image.x = start_x;
                    image.y = start_y;
                    image.scaleX = 0.6;
                    image.scaleY = 0.6;
                    thisback.panel.addChild(image);
                    egret.Tween.get(image).to({ x: end_x, y: end_y }, 500 + Math.floor(Math.random() * 200), egret.Ease.circOut).call((image: eui.Image) => {
                        egret.Tween.removeTweens(image);
                        if (thisback.panel.contains(image)) {
                            thisback.panel.removeChild(image)
                        }
                    }, this, [image])
                }
            }
            let winList: Array<eui.Group> = [];
            let loseList: Array<eui.Group> = [];
            if (DdzVO.getVo().score_my > 0) {
                winList.push(this.panel.userInfoMy);
            } else {
                loseList.push(this.panel.userInfoMy);
            }
            if (DdzVO.getVo().score_right > 0) {
                winList.push(this.panel.userInfoRight);
            } else {
                loseList.push(this.panel.userInfoRight);
            }
            if (DdzVO.getVo().score_left > 0) {
                winList.push(this.panel.userInfoLeft);
            } else {
                loseList.push(this.panel.userInfoLeft);
            }
            if (winList.length == 1) {//地主赢
                DdzVO.getVo().winUser = 0;
            } else {//农民赢
                DdzVO.getVo().winUser = 1;
            }
            var gold//飞筹码金币动画的金额数量
            if (DdzVO.getVo().wChairId_my == DdzVO.getVo().wBankerUser) {
                gold = Math.abs(DdzVO.getVo().score_my / 2)
            } else {
                gold = Math.abs(DdzVO.getVo().score_my)
            }
            for (let i = 0; i < winList.length; i++) {
                for (let j = 0; j < loseList.length; j++) {
                    let end_x = winList[i].x + 20, end_y = winList[i].y + 20;
                    let start_x = loseList[j].x + 20, start_y = loseList[j].y + 20;
                    GoldCoin(this.panel, end_x, end_y, start_x, start_y, gold);
                }
            }

            //得分艺术字体向上飞动画
            let t = egret.setTimeout(() => {
                thisback.panel.score_my.text = Global.getmeishufen(DdzVO.getVo().score_my / 100);
                egret.Tween.get(thisback.panel.score_my).to({ y: thisback.panel.score_my.y - 60, alpha: 1 }, 600, egret.Ease.backOut).call((score: egret.DisplayObject) => {
                    score.y = score.y + 60;
                    egret.Tween.removeTweens(score)
                }, this, [thisback.panel.score_my]);

                thisback.panel.score_right.text = Global.getmeishufen(DdzVO.getVo().score_right / 100);
                egret.Tween.get(thisback.panel.score_right).to({ y: thisback.panel.score_right.y - 60, alpha: 1 }, 600, egret.Ease.backOut).call((score: egret.DisplayObject) => {
                    score.y = score.y + 60;
                    egret.Tween.removeTweens(score)
                }, this, [thisback.panel.score_right]);

                thisback.panel.score_left.text = Global.getmeishufen(DdzVO.getVo().score_left / 100);
                egret.Tween.get(thisback.panel.score_left).to({ y: thisback.panel.score_left.y - 60, alpha: 1 }, 600, egret.Ease.backOut).call((score: egret.DisplayObject) => {
                    score.y = score.y + 60;
                    egret.Tween.removeTweens(score)
                }, this, [thisback.panel.score_left]);
                egret.clearTimeout(t);
                //赢家图片
                thisback.panel.winer_img.scaleX = 0
                thisback.panel.winer_img.scaleY = 0
                thisback.panel.winer_img.rotation = 0
                thisback.panel.winer_img.visible = true
                var str = ""
                if (DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_my) {
                    if (winList.length == 1) {//地主赢
                        str = "DDZ_source_8"
                    } else {//农民赢
                        str = "DDZ_source_22"
                    }
                } else {
                    if (winList.length == 1) {
                        str = "DDZ_source_25"
                    } else {
                        str = "DDZ_source_11"
                    }
                }
                thisback.panel.winer_img.source = str;
                egret.Tween.get(thisback.panel.winer_img).to({ scaleX: 1, scaleY: 1, rotation: 360 }, 400)
                this.globLook = false;
                this.initUserInfo();
            }, this, 1500)
            this.nextGameTimeout();
        }
        //数据恢复
        private dataRecoveryByPlay() {
            this.initRoomInfo();
            this.initUserInfo();
            this.playCards();
            if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {//别人出牌的时候  this.playCards(); 已经刷新了计时器，我出牌的时候没刷，要刷一次
                this.updateRecorder();
            }
            let chess = DdzVO.getVo().chessListBanker;
            for (let i = 0; i < chess.length; i++) {
                this.panel["dizhu_chess" + i].source = Global.getPokerByObjectForDDZ(chess[i]);
            }
            this.panel.trusteeship.visible = true;
            this.panel.zhunbei.visible = false;
            this.panel.R_chess.source = "DDZ_source_34";
            this.panel.L_chess.source = "DDZ_source_34";
            this.panel.R_chessNum.text = DdzVO.getVo().chessListRightLength + "";
            this.panel.L_chessNum.text = DdzVO.getVo().chessListLeftLength + "";
            //清空之前的牌图片
            var poker: components.DdzPoker = null;
            this.chessList.splice(0, this.chessList.length);
            for (let i = 0; i < this.MyChessImg.length; i++) {
                poker = this.panel["my_chess" + i]
                poker.y = this.pokerInitial_y;
                poker.destroy();
                poker.name = "";
            }
            this.MyChessImg.splice(0, this.MyChessImg.length);
            //生成新的图片
            poker = null;
            for (var i = 0; i < DdzVO.getVo().chessListMy.length; i++) {
                poker = this.panel["my_chess" + i]
                poker.init(DdzVO.getVo().chessListMy[i]);
                poker.name = DdzVO.getVo().chessListMy[i].id + ""
                this.MyChessImg.push(this.panel["my_chess" + i]);
            };
            //自己是地主显示地主标志
            if (poker != null && DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_my) {
                poker.init(DdzVO.getVo().chessListMy[i - 1], true);
            }
            //调整牌位置
            this.panel.myChessGroup.width = this.MyChessImg.length * 45 + (126 - 45)
            // if (this.MyChessImg.length > 18) {
            //     this.panel.myChessGroup.x = 175 + (20 - this.MyChessImg.length) * 27.5;
            // } else {
            //     this.panel.myChessGroup.x = 100 + (20 - this.MyChessImg.length) * 27.5;
            // }
            for (let i = 0; i < 20; i++) {
                this.panel["my_chess" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickChess, this);
            }
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.anzhu, this);
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_END, this.songkai, this);
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.songkai2, this);
            DdzVO.getVo().tuoguan = true;
            game.AppFacade.instance.sendNotification(PanelNotify.DDZ.MODIFY_HOSTING_STATUS)
        }
        private dataRecoveryByCall() {
            this.initRoomInfo();
            this.initUserInfo();
            this.updateRecorder();
            this.WaitingForAScore();
            this.panel.zhunbei.visible = false;
            this.panel.dizhu_chess0.source = "DDZ_source_34";
            this.panel.dizhu_chess1.source = "DDZ_source_34";
            this.panel.dizhu_chess2.source = "DDZ_source_34";
            this.panel.R_chess.source = "DDZ_source_34";
            this.panel.L_chess.source = "DDZ_source_34";
            this.panel.R_chessNum.text = DdzVO.getVo().chessListRightLength + "";
            this.panel.L_chessNum.text = DdzVO.getVo().chessListLeftLength + "";
            //清空之前的牌图片
            var poker: components.DdzPoker = null;
            this.chessList.splice(0, this.chessList.length);
            for (let i = 0; i < this.MyChessImg.length; i++) {
                poker = this.panel["my_chess" + i]
                this.MyChessImg[i].y = this.pokerInitial_y;
                this.MyChessImg[i].destroy();
                this.MyChessImg[i].name = "";
            }
            this.MyChessImg.splice(0, this.MyChessImg.length);
            //生成新的图片
            poker = null;
            for (var i = 0; i < DdzVO.getVo().chessListMy.length; i++) {
                poker = this.panel["my_chess" + i]
                poker.init(DdzVO.getVo().chessListMy[i]);
                poker.name = DdzVO.getVo().chessListMy[i].id + ""
                this.MyChessImg.push(poker);
            };
            //自己是地主显示地主标志
            if (poker != null && DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_my) {
                poker.init(DdzVO.getVo().chessListMy[i - 1], true);
            }
            //调整牌位置
            this.panel.myChessGroup.width = this.MyChessImg.length * 45 + (126 - 45)
            // if (this.MyChessImg.length > 18) {
            //     this.panel.myChessGroup.x = 175 + (20 - this.MyChessImg.length) * 27.5;
            // } else {
            //     this.panel.myChessGroup.x = 100 + (20 - this.MyChessImg.length) * 27.5;
            // }
            for (let i = 0; i < 20; i++) {
                this.panel["my_chess" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickChess, this);
            }
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.anzhu, this);
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_END, this.songkai, this);
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.songkai2, this);
            DdzVO.getVo().tuoguan = true;
            game.AppFacade.instance.sendNotification(PanelNotify.DDZ.MODIFY_HOSTING_STATUS)
        }
        //修改托管状态
        private modifyTuoGuan() {
            if (DdzVO.getVo().tuoguan == true) {
                this.panel.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.trusteeshiclose, this)
                this.panel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.trusteeshiclose, this)
                this.panel.chupaiGroup.visible = false;
                this.panel.trusteeship.visible = false;
                this.panel.tuoguanBtn.visible = true;
                //牌变灰
                var colorMatrix = [
                    0.3, 0.6, 0, 0, 0,
                    0.3, 0.6, 0, 0, 0,
                    0.3, 0.6, 0, 0, 0,
                    0, 0, 0, 1, 0
                ];
                var flilter = new egret.ColorMatrixFilter(colorMatrix);
                for (let i = 0; i < this.MyChessImg.length; i++) {
                    this.MyChessImg[i].filters = [flilter];
                }
                this.panel.myChessGroup.touchChildren = false
                this.panel.myChessGroup.touchEnabled = false
                if (this.panel.contains(this.MovieClip)) {
                    this.panel.removeChild(this.MovieClip);
                }
                var g = new eui.Group();
                var data = RES.getRes("ddz_tuoguan_donghua_json");
                var txtr = RES.getRes("ddz_tuoguan_donghua");
                var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("tuoguan"));
                g.addChild(mc1)
                g.horizontalCenter = 0;
                g.bottom = 90
                this.panel.addChild(g);
                mc1.play(-1)
                this.MovieClip = mc1
            } else {
                this.panel.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.trusteeshiclose, this)
                this.panel.chupaiGroup.visible = true;
                this.panel.trusteeship.visible = true;
                this.panel.tuoguanBtn.visible = false;

                for (let i = 0; i < this.MyChessImg.length; i++) {
                    this.MyChessImg[i].filters = null
                }

                this.panel.myChessGroup.touchChildren = true
                this.panel.myChessGroup.touchEnabled = true
                if (this.MovieClip && this.panel.contains(this.MovieClip.parent)) {
                    this.panel.removeChild(this.MovieClip.parent);
                    this.MovieClip.stop()
                    this.MovieClip.parent.removeChild(this.MovieClip)
                    this.MovieClip = null;
                }
            }
        }
        //出牌或抢地主后重置手牌
        private initChessImg(text = null) {
            this.panel.R_chessNum.text = DdzVO.getVo().chessListRightLength + "";
            this.panel.L_chessNum.text = DdzVO.getVo().chessListLeftLength + "";
            //清空之前的牌图片
            this.chessList.splice(0, this.chessList.length);
            for (let i = 0; i < this.MyChessImg.length; i++) {
                this.MyChessImg[i].y = this.pokerInitial_y;
                this.MyChessImg[i].name = "";
                this.MyChessImg[i].destroy();
            }
            this.MyChessImg.splice(0, this.MyChessImg.length);
            //生成新的图片
            var poker: components.DdzPoker = null;
            for (var i = 0; i < DdzVO.getVo().chessListMy.length; i++) {
                poker = this.panel["my_chess" + i]
                poker.init(DdzVO.getVo().chessListMy[i]);
                poker.name = DdzVO.getVo().chessListMy[i].id + ""
                this.MyChessImg.push(poker);
            };
            //自己是地主显示地主标志
            if (poker != null && DdzVO.getVo().wBankerUser == DdzVO.getVo().wChairId_my) {
                poker.init(DdzVO.getVo().chessListMy[i - 1], true);
            }
            //调整牌位置
            this.panel.myChessGroup.width = this.MyChessImg.length * 45 + (126 - 45)

            // if (this.MyChessImg.length > 18) {
            //     this.panel.myChessGroup.x = 175 + (20 - this.MyChessImg.length) * 27.5;
            // } else {
            //     this.panel.myChessGroup.x = 100 + (20 - this.MyChessImg.length) * 27.5;
            // }
            //确定地主后第一次重置手牌时地主牌做动画
            if (text == PanelNotify.DDZ.END_CALL_SCORE) {
                for (let i = 0; i < DdzVO.getVo().chessListMy.length; i++) {
                    var poker: components.DdzPoker = this.panel["my_chess" + i]
                    if (DdzVO.getVo().cbBankerCard.indexOf(Number(poker.name)) != -1) {
                        poker.y = this.pokerEnd_y;
                        egret.Tween.get(poker).to({ y: this.pokerInitial_y }, 500, egret.Ease.sineInOut).call((img: components.DdzPoker) => {
                            egret.Tween.removeTweens(img);
                        }, this, [poker]);
                    }
                };
            }
        }
        //点击牌后变换位置
        private clickChess(e: egret.Event) {
            if (this.lock != 0) {
                return;
            }
            // this.chessList.splice(0, this.chessList.length);
            // for (let i in this.MyChessImg) {
            //     if (this.MyChessImg[i].y != this.pokerInitial_y) {
            //         this.chessList.push(this.MyChessImg[i].name);
            //     }
            // }

            if (e.currentTarget.y == this.pokerInitial_y) {
                if (this.chessList.indexOf(e.currentTarget.name) == -1) {
                    this.chessList.push(e.currentTarget.name);
                }
                egret.Tween.get(e.currentTarget).to({ y: this.pokerEnd_y }, 150, egret.Ease.sineInOut).call((image: eui.Image) => {
                    egret.Tween.removeTweens(image);
                }, this, [e.currentTarget]);
            } else {
                let index = this.chessList.indexOf(e.currentTarget.name);
                if (index != -1) {
                    this.chessList.splice(index, 1);
                }
                egret.Tween.get(e.currentTarget).to({ y: this.pokerInitial_y }, 150, egret.Ease.sineInOut).call((image: eui.Image) => {
                    egret.Tween.removeTweens(image);
                }, this, [e.currentTarget]);
            }
            SoundManage.startYinxiaoLoad("send_card_mp3")
            this.compare();
        }
        //点击重选时除了清空选中的牌之外，还需要清空提示的次数，下次点提示从第一张弹出
        private chongxuan(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            this.tishiNumber = 0;
            this.chongxuan_tishi();
            this.compare();
        }

        //按住屏幕启动移动事件
        private anzhu(event: egret.TouchEvent) {
            this.lock = 0;
            this.lock2 = 0;
            this.panel.myChessGroup.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.yidong, this);
            this.shp.graphics.drawRect(0, 0, 45, 170);
            this.panel.addChild(this.shp);
        }
        //移动鼠标选中牌
        private yidong(event: egret.TouchEvent) {
            this.lock = 1;
            for (var i: number = 0; i < this.MyChessImg.length; i++) {
                this.shp.x = this.MyChessImg[i].x + this.panel.myChessGroup.x;
                this.shp.y = this.MyChessImg[i].y + this.panel.myChessGroup.y;
                var flag: boolean = this.shp.hitTestPoint(event.stageX, event.stageY);
                if (flag) {
                    if (this.selectList.indexOf(i) == -1) {
                        if (this.MyChessImg[i].y == this.pokerInitial_y) {
                            if (this.chessList.indexOf(this.MyChessImg[i].name) == -1) {
                                this.chessList.push(this.MyChessImg[i].name);
                            }
                            egret.Tween.get(this.MyChessImg[i]).to({ y: this.pokerEnd_y }, 150, egret.Ease.sineInOut).call((image: eui.Image) => {
                                egret.Tween.removeTweens(image);
                            }, this, [this.MyChessImg[i]]);
                        } else {
                            let index = this.chessList.indexOf(this.MyChessImg[i].name);
                            if (index != -1) {
                                this.chessList.splice(index, 1);
                            }
                            egret.Tween.get(this.MyChessImg[i]).to({ y: this.pokerInitial_y }, 150, egret.Ease.sineInOut).call((image: eui.Image) => {
                                egret.Tween.removeTweens(image);
                            }, this, [this.MyChessImg[i]]);
                        }
                        this.selectList[i] = i;
                        SoundManage.startYinxiaoLoad("send_card_mp3")
                    }
                }
            }
        }
        // 松开屏幕移除移动事件
        private songkai(e: egret.TouchEvent) {
            if (this.lock == 0) {
                return;
            }
            this.lock2 = 1;
            this.selectList.splice(0, this.selectList.length);
            if (this.panel.contains(this.shp)) {
                this.panel.removeChild(this.shp);
            }
            this.panel.myChessGroup.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.yidong, this);
            this.compare();
        }
        private songkai2(e: egret.TouchEvent) {
            if (this.lock == 0) {
                return;
            }
            if (this.lock2 == 1) {
                return;
            }
            this.selectList.splice(0, this.selectList.length);
            if (this.panel.contains(this.shp)) {
                this.panel.removeChild(this.shp);
            }
            this.panel.myChessGroup.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.yidong, this);
            this.compare();
        }
        //比较我选中的牌是否能打出去
        private compare() {
            if (this.myCanPlay != true) {
                return;
            }
            let canPlay = ChessCompare.compare(this.chessList);
            if (canPlay) {
                this.panel.chupai.enabled = true;
            } else {
                this.panel.chupai.enabled = false;
            }
        }
        //传入牌型播放音乐
        private sound(upPlayType: string, wOutCardUser: string) {
            var path: string = "";
            var _thisBack = this;
            var typeImg = "";
            switch (upPlayType) {
                case ChessType.c1: {
                    path = "female_" + DdzVO.getVo().chessListUp[0].value + "_mp3";
                    break;
                };
                case ChessType.c2: {
                    path = "female_pair" + DdzVO.getVo().chessListUp[0].value + "_mp3";
                    break;
                };
                case ChessType.c3: {
                    path = "female_sange_mp3";
                    break;
                }
                case ChessType.c31: {
                    path = "female_sandaiyi_mp3";
                    break;
                };
                case ChessType.c32: {
                    path = "female_sandaier_mp3";
                    break;
                };
                case ChessType.c411: {
                    path = "female_sidaier_mp3";
                    break;
                };
                case ChessType.c422: {
                    path = "female_sidaierdui_mp3";
                    break;
                };
                case ChessType.c1122: {
                    var group: eui.Group;
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_right) {
                        group = this.panel.right_playGroup
                    }
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_left) {
                        group = this.panel.left_playGroup
                    }
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {
                        group = this.panel.my_playGroup
                    } path = "female_liandui_mp3";
                    var data = RES.getRes("ddz_liandui_json");
                    var txtr = RES.getRes("ddz_liandui");
                    var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                    var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("liandui"));
                    mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                        let t = egret.setTimeout(() => {
                            if (mc1.parent.contains(mc1)) {
                                mc1.parent.removeChild(mc1);
                            }
                            egret.clearTimeout(t)
                        }, this, 500)
                    }, this);
                    mc1.x = 500;
                    mc1.y = 200
                    mc1.x = (group.numChildren * 30 / 2) - (300 / 2) + 20
                    mc1.y = 20
                    group.addChild(mc1)
                    mc1.play();
                    break;
                };
                case ChessType.c123: {
                    var group: eui.Group;
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_right) {
                        group = this.panel.right_playGroup
                    }
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_left) {
                        group = this.panel.left_playGroup
                    }
                    if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {
                        group = this.panel.my_playGroup
                    }
                    path = "female_shunzi_mp3";
                    var data = RES.getRes("ddz_shunzi_json");
                    var txtr = RES.getRes("ddz_shunzi");
                    var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                    var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("shunzi"));
                    mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                        let t = egret.setTimeout(() => {
                            if (mc1.parent.contains(mc1)) {
                                mc1.parent.removeChild(mc1);
                            }
                            egret.clearTimeout(t)
                        }, this, 500)
                    }, this);

                    mc1.x = (group.numChildren * 30 / 2) - (300 / 2) + 20
                    mc1.y = 20
                    group.addChild(mc1)
                    mc1.play();
                    break;
                };
                case ChessType.c11122234: {
                    typeImg = "DDZ_type_feiji"
                    SoundManage.startYinxiaoLoad("female_feijidaicibang_mp3", 1);
                    let feiji: eui.Image = new eui.Image("DDZ_source_38");
                    feiji.verticalCenter = 0;
                    feiji.x = GameConfig.curWidth();
                    this.panel.addChild(feiji);

                    egret.Tween.get(feiji).to({ x: 0 - feiji.width }, 700, egret.Ease.sineInOut).call(function () {
                        egret.Tween.removeTweens(feiji);
                        if (_thisBack.panel.contains(feiji)) {
                            _thisBack.panel.removeChild(feiji);
                        }
                        var data = RES.getRes("ddzSpecialEffects_json");
                        var txtr = RES.getRes("ddzSpecialEffects");
                        var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                        var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("feiji"));
                        mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                            if (_thisBack.panel.contains(mc1.parent)) {
                                _thisBack.panel.removeChild(mc1.parent);
                            }
                            mc1.parent.removeChild(mc1)
                            mc1.stop();
                            mc1 = null;
                        }, this);
                        var g = new eui.Group();
                        g.addChild(mc1)
                        g.width = 65
                        g.verticalCenter = "0"
                        g.horizontalCenter = "0"
                        _thisBack.panel.addChild(g)
                        mc1.play();
                        SoundManage.startYinxiaoLoad("feiji_mp3", 1);
                    });
                    break;
                };
                case ChessType.c1112223344: {
                    typeImg = "DDZ_type_feiji"
                    SoundManage.startYinxiaoLoad("female_feijidaicibang_mp3", 1);
                    let feiji: eui.Image = new eui.Image("DDZ_source_38");
                    feiji.verticalCenter = 0;
                    feiji.x = GameConfig.curWidth();
                    this.panel.addChild(feiji);

                    egret.Tween.get(feiji).to({ x: 0 - feiji.width }, 700, egret.Ease.sineInOut).call(function () {
                        egret.Tween.removeTweens(feiji);
                        if (_thisBack.panel.contains(feiji)) {
                            _thisBack.panel.removeChild(feiji);
                        }
                        var data = RES.getRes("ddzSpecialEffects_json");
                        var txtr = RES.getRes("ddzSpecialEffects");
                        var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                        var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("feiji"));
                        mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                            if (_thisBack.panel.contains(mc1.parent)) {
                                _thisBack.panel.removeChild(mc1.parent);
                            }
                            mc1.parent.removeChild(mc1)
                            mc1.stop();
                            mc1 = null;
                        }, this);
                        var g = new eui.Group();
                        g.addChild(mc1)
                        g.width = 65
                        g.verticalCenter = "0"
                        g.horizontalCenter = "0"
                        _thisBack.panel.addChild(g)
                        mc1.play();
                    });
                    SoundManage.startYinxiaoLoad("feiji_mp3", 1);
                    break;
                };
                case ChessType.c111222: {
                    typeImg = "DDZ_type_feiji"
                    SoundManage.startYinxiaoLoad("female_feiji_mp3", 1);
                    let feiji: eui.Image = new eui.Image("DDZ_source_38");
                    feiji.verticalCenter = 0;
                    feiji.x = GameConfig.curWidth();
                    this.panel.addChild(feiji);

                    egret.Tween.get(feiji).to({ x: 0 - feiji.width }, 700, egret.Ease.sineInOut).call(function () {
                        egret.Tween.removeTweens(feiji);
                        if (_thisBack.panel.contains(feiji)) {
                            _thisBack.panel.removeChild(feiji);
                        }
                        var data = RES.getRes("ddzSpecialEffects_json");
                        var txtr = RES.getRes("ddzSpecialEffects");
                        var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                        var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("feiji"));
                        mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                            if (_thisBack.panel.contains(mc1.parent)) {
                                _thisBack.panel.removeChild(mc1.parent);
                            }
                            mc1.parent.removeChild(mc1)
                            mc1.stop();
                            mc1 = null;
                        }, this);
                        var g = new eui.Group();
                        g.addChild(mc1)
                        g.width = 65
                        g.verticalCenter = "0"
                        g.horizontalCenter = "0"
                        _thisBack.panel.addChild(g)
                        mc1.play();
                    });
                    SoundManage.startYinxiaoLoad("feiji_mp3", 1);
                    break;
                };
                case ChessType.c4: {
                    typeImg = "DDZ_type_zhadan"
                    DdzVO.getVo().cbIsDoubleNumber *= 2;
                    this.initRoomInfo();
                    SoundManage.startYinxiaoLoad("female_zhadan_mp3", 1);
                    let zhadan: eui.Image = new eui.Image("DDZ_source_37");
                    zhadan.anchorOffsetX = zhadan.width / 2;
                    zhadan.anchorOffsetY = zhadan.height / 2;
                    zhadan.horizontalCenter = "0";
                    zhadan.y = 0 - (zhadan.height / 2);
                    zhadan.rotation = 0;
                    this.panel.addChild(zhadan);

                    egret.Tween.get(zhadan).to({ y: 330, rotation: 130 }, 500, egret.Ease.sineInOut).call(function () {
                        egret.Tween.removeTweens(zhadan);
                        if (_thisBack.panel.contains(zhadan)) {
                            _thisBack.panel.removeChild(zhadan);
                        }
                        var data = RES.getRes("ddzSpecialEffects_json");
                        var txtr = RES.getRes("ddzSpecialEffects");
                        var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                        var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("zhadan"));
                        mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                            if (_thisBack.panel.contains(mc1.parent)) {
                                _thisBack.panel.removeChild(mc1.parent);
                            }
                            mc1.parent.removeChild(mc1)
                            mc1.stop();
                            mc1 = null;
                        }, this);
                        var g = new eui.Group();
                        g.addChild(mc1)
                        g.width = 255
                        g.horizontalCenter = "0";
                        g.y = 200
                        _thisBack.panel.addChild(g)
                        mc1.play();
                        SoundManage.startYinxiaoLoad("bomb_mp3", 1)
                    });
                    break;
                };
                case ChessType.cboom: {
                    typeImg = "DDZ_type_huojian"
                    DdzVO.getVo().cbIsDoubleNumber *= 2;
                    this.initRoomInfo();
                    SoundManage.startYinxiaoLoad("female_huojian_mp3", 1)
                    var data = RES.getRes("ddzSpecialEffects_json");
                    var txtr = RES.getRes("ddzSpecialEffects");
                    var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                    var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("huojian"));
                    mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                        if (_thisBack.panel.contains(mc1.parent)) {
                            _thisBack.panel.removeChild(mc1.parent);
                            mc1.parent.removeChild(mc1)
                            mc1.stop()
                            mc1 = null;
                        }
                    }, this);
                    var g = new eui.Group();
                    g.addChild(mc1)
                    g.width = 400//引擎缺陷，无法得到egret.MovieClip的实时宽高，想要知道最大宽度只能到动画资源去看，更换动画资源后需要更改此值否则动画无法居中播放
                    g.horizontalCenter = "0";
                    _thisBack.panel.addChild(g)
                    mc1.play();
                    SoundManage.startYinxiaoLoad("bomb_mp3", 1)
                    break;
                };
            }

            if (path != "") {
                SoundManage.startYinxiaoLoad(path, 1)
            }
            if (typeImg != "") {
                var img = new eui.Image(typeImg)
                img.bottom = "0"
                img.horizontalCenter = "0"
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_my) {
                    this.panel.my_playGroup.addChild(img)
                }
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_right) {
                    this.panel.right_playGroup.addChild(img)
                }
                if (DdzVO.getVo().wOutCardUser == DdzVO.getVo().wChairId_left) {
                    this.panel.left_playGroup.addChild(img)
                }
            }
        }
        //清空面板到第一次
        private clearView() {
            this.globLook = false
            this.panel.winer_img.visible = false
            this.panel.beishu.text = "";
            this.panel.difen.text = "";
            for (var i = 0; i < 20; i++) {
                var poker: components.DdzPoker = this.panel["my_chess" + i]
                poker.filters = null
                poker.destroy();
                poker.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.clickChess, this);
            }
            this.panel.myChessGroup.width = 17 * 45 + (126 - 45)
            this.panel.myChessGroup.touchChildren = true
            this.panel.myChessGroup.touchEnabled = true
            this.panel.myChessGroup.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.anzhu, this);
            this.panel.myChessGroup.removeEventListener(egret.TouchEvent.TOUCH_END, this.songkai, this);
            this.panel.myChessGroup.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.songkai2, this);
            this.panel.R_chess.source = "";
            this.panel.L_chess.source = "";
            this.panel.R_chessNum.text = "";
            this.panel.L_chessNum.text = "";
            egret.Tween.removeTweens(this.panel.jingbao_left)
            egret.Tween.removeTweens(this.panel.jingbao_right)
            this.panel.jingbao_left.visible = false
            this.panel.jingbao_right.visible = false
            //地主牌
            this.panel.dizhu_chess0.source = "";
            this.panel.dizhu_chess1.source = "";
            this.panel.dizhu_chess2.source = "";
            this.panel.dizhu_chess0.scaleX = 1
            this.panel.dizhu_chess1.scaleX = 1
            this.panel.dizhu_chess2.scaleX = 1
            this.panel.my_playGroup.removeChildren();
            this.panel.right_playGroup.removeChildren();
            this.panel.left_playGroup.removeChildren();

            this.panel.zhuangImg_my.visible = false;
            this.panel.zhuangImg_right.visible = false;
            this.panel.zhuangImg_left.visible = false;

            this.panel.userInfoRight.visible = false;
            this.panel.userInfoLeft.visible = false;

            //倒计时
            this.panel.daojishi_L.visible = true
            this.panel.daojishi_R.visible = true
            this.panel.daojishi_my.visible = true
            this.panel.game_ok_right.visible = false;
            this.panel.game_ok_my.visible = false;
            this.panel.game_ok_left.visible = false;
            //叫分状态
            this.panel.fen_my.source = "";
            this.panel.fen_left.source = "";
            this.panel.fen_right.source = "";
            //过牌标记
            this.panel.r_too.source = "";
            this.panel.l_too.source = "";
            this.panel.my_too.source = "";

            //叫分按钮
            this.panel.jiaofenGroup.visible = true
            this.panel.bujiao.visible = false;
            this.panel.fen1.visible = false;
            this.panel.fen2.visible = false;
            this.panel.fen3.visible = false;
            this.panel.bujiao.enabled = true;
            this.panel.fen1.enabled = true;
            this.panel.fen2.enabled = true;
            this.panel.fen3.enabled = true;
            //托管状态重置
            this.panel.trusteeship.visible = false;
            this.panel.tuoguanBtn.visible = false;

            this.panel.myChessGroup.touchChildren = true
            this.panel.myChessGroup.touchEnabled = true
            //出牌按钮
            this.panel.chupaiGroup.visible = true;
            this.panel.chupai.visible = false;
            this.panel.chongxuan.visible = false;
            this.panel.tishi.visible = false;
            this.panel.buchu.visible = false;
            this.panel.chupai.enabled = true;
            this.panel.chongxuan.enabled = true;
            this.panel.tishi.enabled = true;
            this.panel.buchu.enabled = true;
            //准备按钮
            this.panel.zhunbei.visible = true;
            //最终得分
            this.panel.score_left.text = "";
            this.panel.score_right.text = "";
            this.panel.score_my.text = "";

            this.kechuNumber = 0;
            this.tishiNumber = 0;
            this.chessList = [];
            this.selectList = [];
            this.lock = 0;
            this.lock2 = 0;
            egret.clearTimeout(this.CallScoreTime)//清楚自动叫分定时器
        }
        //点击下拉菜单
        private menu_click() {
            if (this.panel.menu_button.name == "on") {//收起菜单
                egret.Tween.removeTweens(this.panel.menu_button)
                egret.Tween.removeTweens(this.panel.menu_group)
                this.panel.menu_button.name = "off"
                egret.Tween.get(this.panel.menu_button).to({ rotation: 0 }, 300)
                egret.Tween.get(this.panel.menu_group).to({ x: -260 }, 300).call((menu_group: eui.Group) => {
                    menu_group.visible = false;
                }, this, [this.panel.menu_group])
            } else {                                      //弹出菜单
                egret.Tween.removeTweens(this.panel.menu_button)
                egret.Tween.removeTweens(this.panel.menu_group)
                this.panel.menu_button.name = "on"
                this.panel.menu_group.visible = true;
                egret.Tween.get(this.panel.menu_button).to({ rotation: 90 }, 300)
                egret.Tween.get(this.panel.menu_group).to({ x: 0 }, 300)
            }
        }
        //返回大厅
        private fanhuidatingClick(event: egret.TouchEvent): void {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            if (DdzVO.getVo().game_state == 1) {
                let obj = new Object();
                obj[InstructionsEnum.TEXT] = "请等待游戏结束后离开！";
                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
            } else {
                let obj = new Object();
                obj[InstructionsEnum.CODE] = PanelNotify.DDZ.CLOSE_PLAY_GAME;
                obj[InstructionsEnum.TEXT] = "确定要离开游戏吗？";
                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
            }
        }
        //帮助
        private helpClick(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_HELP_DDZ);
        }
        //设置
        private setClick(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_SETTING);
        }
        //点击反馈
        private fankuiClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_FANKUI, InstructionsEnum.GAME_TYPE_NAME.DDZ)
        }
        //点击记录
        private jiluClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            var obj = {
                gameType: InstructionsEnum.GAME_TYPE_NAME.DDZ,
                roomType: InstructionsEnum.LEVEL_GAME
            }
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_JILU, JSON.stringify(obj))
        }
        //刷新记牌器
        private updateRecorder() {
            //记牌器初始默认54张牌，发牌的时候扣除我的手牌，确定地主后若地主是我则扣除地主牌。之后只在其他两家出牌的时候扣牌
            for (let i = 0; i < DdzVO.getVo().upPlayList.length; i++) {
                let poker = Poker_DDZ.chessArray[DdzVO.getVo().upPlayList[i]];
                let value = poker.value;
                if (Global.isNotEmpty(DdzVO.getVo().chessListWhole[value])) {
                    DdzVO.getVo().chessListWhole[value]--;
                }
            }
            let chessList: Object = DdzVO.getVo().chessListWhole;
            for (let i in chessList) {
                this.panel["recorder_" + i].text = chessList[i] + "";
            }
        }
        //托管
        private trusteeshipClick(event: egret.TouchEvent) {
            this.chongxuan_tishi();
            SoundManage.startAnniuBtnLoad();
            let obj = {
                cbTrustee: 1
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_Trustee, obj);
        }
        //取消托管
        private trusteeshiclose(event: egret.TouchEvent) {
            event.stopImmediatePropagation()
            SoundManage.startAnniuBtnLoad();
            let obj = {
                cbTrustee: 0
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_Trustee, obj);
        }
        //准备
        private zhunbeiClick(event: egret.TouchEvent): void {
            SoundManage.startAnniuBtnLoad();
            this.panel.winer_img.visible = false
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataDdz.CMD_GP_UserMate, {});
        }
        //金币拆分
        private qiegeJinbi(fen: number): Array<any> {
            let Fen = fen
            let imgList: Array<any> = [];
            let guigeList = this.bet_chip;
            for (let j = guigeList.length; j >= 0; j--) {
                let len = Math.floor(Fen / guigeList[j]);
                if (len != 0) {
                    for (var k = 0; k < len; k++) {
                        imgList.push(guigeList[j]);
                        Fen -= guigeList[j];
                    }
                }
            }
            return imgList
        }
        //下一局准备倒计时
        public nextGameTimeout() {
            if (this.NextGameTime == null) {
                this.panel.game_ok_my.init(DdzVO.getVo().cbTimeOutExitGame)
                this.NextGameTime = egret.setTimeout(() => {
                    if (Global.isNotEmpty(DdzVO.getVo().wTableId_my) && Global.isNotEmpty(DdzVO.getVo().wChairId_my)) {
                        let data = {
                            wTableID: DdzVO.getVo().wTableId_my,
                            wChairID: DdzVO.getVo().wChairId_my,
                            cbForceLeave: 1
                        }
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.DDZ, RegDataGamePublic.CMD_GP_LeaveGame, data, true);
                    }
                    egret.clearTimeout(this.NextGameTime)
                    this.NextGameTime = null;
                }, this, DdzVO.getVo().cbTimeOutExitGame * 1000)
                InstructionsEnum.GAME_TIMEOUT_LIST.push(this.NextGameTime)
            }
        }
    }
}